home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / snmp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  16.6 KB  |  438 lines

  1. /*++
  2.  
  3. Copyright (C) 1992-1996 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     snmp.h
  8.  
  9. Abstract:
  10.  
  11.     Definitions for SNMP Extension Agent development.
  12.  
  13. --*/
  14.  
  15. #ifndef _INC_SNMP
  16. #define _INC_SNMP
  17. #pragma option push -b
  18.  
  19.  
  20. ///////////////////////////////////////////////////////////////////////////////
  21. //                                                                           //
  22. // Additional header files                                                   //
  23. //                                                                           //
  24. ///////////////////////////////////////////////////////////////////////////////
  25.  
  26.  
  27. #include <windows.h>
  28.  
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. ///////////////////////////////////////////////////////////////////////////////
  35. //                                                                           //
  36. // SNMP API return type definitions                                          //
  37. //                                                                           //
  38. ///////////////////////////////////////////////////////////////////////////////
  39.  
  40. #define SNMPAPI                         INT
  41. #define SNMP_FUNC_TYPE                  WINAPI
  42.  
  43. ///////////////////////////////////////////////////////////////////////////////
  44. //                                                                           //
  45. // SNMP API return code definitions                                          //
  46. //                                                                           //
  47. ///////////////////////////////////////////////////////////////////////////////
  48.  
  49. #define SNMPAPI_NOERROR                 TRUE
  50. #define SNMPAPI_ERROR                   FALSE
  51.  
  52. ///////////////////////////////////////////////////////////////////////////////
  53. //                                                                           //
  54. // SNMP API error code definitions                                           //
  55. //                                                                           //
  56. ///////////////////////////////////////////////////////////////////////////////
  57.  
  58. #define SNMP_MEM_ALLOC_ERROR            1
  59.  
  60. ///////////////////////////////////////////////////////////////////////////////
  61. //                                                                           //
  62. // BER API error code definitions                                            //
  63. //                                                                           //
  64. ///////////////////////////////////////////////////////////////////////////////
  65.  
  66. #define SNMP_BERAPI_INVALID_LENGTH      10
  67. #define SNMP_BERAPI_INVALID_TAG         11
  68. #define SNMP_BERAPI_OVERFLOW            12
  69. #define SNMP_BERAPI_SHORT_BUFFER        13
  70. #define SNMP_BERAPI_INVALID_OBJELEM     14
  71.  
  72. ///////////////////////////////////////////////////////////////////////////////
  73. //                                                                           //
  74. // PDU API error code definitions                                            //
  75. //                                                                           //
  76. ///////////////////////////////////////////////////////////////////////////////
  77.  
  78. #define SNMP_PDUAPI_UNRECOGNIZED_PDU    20
  79. #define SNMP_PDUAPI_INVALID_ES          21
  80. #define SNMP_PDUAPI_INVALID_GT          22
  81.  
  82. ///////////////////////////////////////////////////////////////////////////////
  83. //                                                                           //
  84. // AUTH API error code definitions                                           //
  85. //                                                                           //
  86. ///////////////////////////////////////////////////////////////////////////////
  87.  
  88. #define SNMP_AUTHAPI_INVALID_VERSION    30
  89. #define SNMP_AUTHAPI_INVALID_MSG_TYPE   31
  90. #define SNMP_AUTHAPI_TRIV_AUTH_FAILED   32
  91.  
  92. ///////////////////////////////////////////////////////////////////////////////
  93. //                                                                           //
  94. // SNMP PDU error status definitions                                         //
  95. //                                                                           //
  96. ///////////////////////////////////////////////////////////////////////////////
  97.  
  98. #define SNMP_ERRORSTATUS_NOERROR        0
  99. #define SNMP_ERRORSTATUS_TOOBIG         1
  100. #define SNMP_ERRORSTATUS_NOSUCHNAME     2
  101. #define SNMP_ERRORSTATUS_BADVALUE       3
  102. #define SNMP_ERRORSTATUS_READONLY       4
  103. #define SNMP_ERRORSTATUS_GENERR         5
  104.  
  105. ///////////////////////////////////////////////////////////////////////////////
  106. //                                                                           //
  107. // SNMP PDU generic trap definitions                                         //
  108. //                                                                           //
  109. ///////////////////////////////////////////////////////////////////////////////
  110.  
  111. #define SNMP_GENERICTRAP_COLDSTART      0
  112. #define SNMP_GENERICTRAP_WARMSTART      1
  113. #define SNMP_GENERICTRAP_LINKDOWN       2
  114. #define SNMP_GENERICTRAP_LINKUP         3
  115. #define SNMP_GENERICTRAP_AUTHFAILURE    4
  116. #define SNMP_GENERICTRAP_EGPNEIGHLOSS   5
  117. #define SNMP_GENERICTRAP_ENTERSPECIFIC  6
  118.  
  119. ///////////////////////////////////////////////////////////////////////////////
  120. //                                                                           //
  121. // BER encoding definitions                                                  //
  122. //                                                                           //
  123. ///////////////////////////////////////////////////////////////////////////////
  124.  
  125. #define ASN_UNIVERSAL                   0x00
  126. #define ASN_APPLICATION                 0x40
  127. #define ASN_CONTEXTSPECIFIC             0x80
  128. #define ASN_PRIVATE                     0xC0
  129.  
  130. #define ASN_PRIMATIVE                   0x00
  131. #define ASN_CONSTRUCTOR                 0x20
  132.  
  133. //
  134. // For BER tags with a number ranging from 0 to 30 (inclusive), the
  135. // identifier octets consists of a single octet encoded as follows:
  136. //
  137. //   7 6 5 4 3 2 1 0
  138. //  +---+-+---------+
  139. //  |Cls|P| Tag Num |
  140. //  +---+-+---------+
  141. //
  142. //  where
  143. //
  144. //      Cls - is the class of the tag
  145. //
  146. //          00 - universal
  147. //          01 - application
  148. //          10 - context-specific
  149. //          11 - private
  150. //
  151. //      P - indicates whether encoding is primitive
  152. //
  153. //           0 - primitive
  154. //           1 - constructed
  155. //
  156. //      Tag Num - is the number of the tag
  157. //
  158.  
  159. ///////////////////////////////////////////////////////////////////////////////
  160. //                                                                           //
  161. // ASN.1 simple types                                                        //
  162. //                                                                           //
  163. ///////////////////////////////////////////////////////////////////////////////
  164.  
  165. #define ASN_INTEGER                (ASN_UNIVERSAL|ASN_PRIMATIVE|0x02)
  166. #define ASN_OCTETSTRING            (ASN_UNIVERSAL|ASN_PRIMATIVE|0x04)
  167. #define ASN_NULL                   (ASN_UNIVERSAL|ASN_PRIMATIVE|0x05)
  168. #define ASN_OBJECTIDENTIFIER       (ASN_UNIVERSAL|ASN_PRIMATIVE|0x06)
  169.  
  170. ///////////////////////////////////////////////////////////////////////////////
  171. //                                                                           //
  172. // ASN.1 constructor types                                                   //
  173. //                                                                           //
  174. ///////////////////////////////////////////////////////////////////////////////
  175.  
  176. #define ASN_SEQUENCE               (ASN_UNIVERSAL|ASN_CONSTRUCTOR|0x10)
  177. #define ASN_SEQUENCEOF             ASN_SEQUENCE
  178.  
  179. ///////////////////////////////////////////////////////////////////////////////
  180. //                                                                           //
  181. // ASN.1 application specific primatives                                     //
  182. //                                                                           //
  183. ///////////////////////////////////////////////////////////////////////////////
  184.  
  185. #define ASN_RFC1155_IPADDRESS      (ASN_APPLICATION|ASN_PRIMATIVE|0x00)
  186. #define ASN_RFC1155_COUNTER        (ASN_APPLICATION|ASN_PRIMATIVE|0x01)
  187. #define ASN_RFC1155_GAUGE          (ASN_APPLICATION|ASN_PRIMATIVE|0x02)
  188. #define ASN_RFC1155_TIMETICKS      (ASN_APPLICATION|ASN_PRIMATIVE|0x03)
  189. #define ASN_RFC1155_OPAQUE         (ASN_APPLICATION|ASN_PRIMATIVE|0x04)
  190. #define ASN_RFC1213_DISPSTRING     ASN_OCTETSTRING
  191.  
  192. ///////////////////////////////////////////////////////////////////////////////
  193. //                                                                           //
  194. // ASN.1 application specific constructors                                   //
  195. //                                                                           //
  196. ///////////////////////////////////////////////////////////////////////////////
  197.  
  198. #define ASN_RFC1157_GETREQUEST     (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x00)
  199. #define ASN_RFC1157_GETNEXTREQUEST (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x01)
  200. #define ASN_RFC1157_GETRESPONSE    (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x02)
  201. #define ASN_RFC1157_SETREQUEST     (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x03)
  202. #define ASN_RFC1157_TRAP           (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x04)
  203.  
  204. ///////////////////////////////////////////////////////////////////////////////
  205. //                                                                           //
  206. // SNMP ASN type definitions                                                 //
  207. //                                                                           //
  208. ///////////////////////////////////////////////////////////////////////////////
  209.  
  210. typedef struct {
  211.     BYTE * stream;              // pointer to octet stream
  212.     UINT   length;              // number of octets in stream
  213.     BOOL   dynamic;             // true if octets must be freed
  214. } AsnOctetString;
  215.  
  216. typedef struct {
  217.     UINT   idLength;            // number of integers in oid
  218.     UINT * ids;                 // pointer to integer stream
  219. } AsnObjectIdentifier;
  220.  
  221. typedef LONG                    AsnInteger;
  222. typedef DWORD                   AsnCounter;
  223. typedef DWORD                   AsnGauge;
  224. typedef DWORD                   AsnTimeticks;
  225.  
  226. typedef AsnOctetString          AsnSequence;
  227. typedef AsnOctetString          AsnImplicitSequence;
  228. typedef AsnOctetString          AsnIPAddress;
  229. typedef AsnOctetString          AsnDisplayString;
  230. typedef AsnOctetString          AsnOpaque;
  231.  
  232. typedef AsnObjectIdentifier     AsnObjectName;
  233. typedef AsnIPAddress            AsnNetworkAddress;
  234.  
  235. typedef struct {
  236.     BYTE asnType;
  237.     union {
  238.         AsnInteger              number;
  239.         AsnOctetString          string;
  240.         AsnObjectIdentifier     object;
  241.         AsnSequence             sequence;
  242.         AsnIPAddress            address;
  243.         AsnCounter              counter;
  244.         AsnGauge                gauge;
  245.         AsnTimeticks            ticks;
  246.         AsnOpaque               arbitrary;
  247.     } asnValue;
  248. } AsnAny;
  249.  
  250. typedef AsnAny                  AsnObjectSyntax;
  251.  
  252. ///////////////////////////////////////////////////////////////////////////////
  253. //                                                                           //
  254. // SNMP API type definitions                                                 //
  255. //                                                                           //
  256. ///////////////////////////////////////////////////////////////////////////////
  257.  
  258. typedef struct vb {
  259.     AsnObjectName    name;      // variable's object identifer
  260.     AsnObjectSyntax  value;     // variable's value (in asn terms)
  261. } RFC1157VarBind;
  262.  
  263. typedef struct {
  264.     RFC1157VarBind * list;      // array of variable bindings
  265.     UINT             len;       // number of bindings in array
  266. } RFC1157VarBindList;
  267.  
  268. ///////////////////////////////////////////////////////////////////////////////
  269. //                                                                           //
  270. // SNMP API prototypes                                                       //
  271. //                                                                           //
  272. ///////////////////////////////////////////////////////////////////////////////
  273.  
  274. SNMPAPI
  275. SNMP_FUNC_TYPE
  276. SnmpUtilOidCpy(
  277.     OUT AsnObjectIdentifier *DstObjId,
  278.     IN  AsnObjectIdentifier *SrcObjId
  279.     );
  280.  
  281. SNMPAPI
  282. SNMP_FUNC_TYPE
  283. SnmpUtilOidAppend(
  284.     IN OUT AsnObjectIdentifier *DstObjId,
  285.     IN     AsnObjectIdentifier *SrcObjId
  286.     );
  287.  
  288. SNMPAPI
  289. SNMP_FUNC_TYPE
  290. SnmpUtilOidNCmp(
  291.     IN AsnObjectIdentifier *ObjIdA,
  292.     IN AsnObjectIdentifier *ObjIdB,
  293.     IN UINT                 Len
  294.     );
  295.  
  296. SNMPAPI
  297. SNMP_FUNC_TYPE
  298. SnmpUtilOidCmp(
  299.     IN AsnObjectIdentifier *ObjIdA,
  300.     IN AsnObjectIdentifier *ObjIdB
  301.     );
  302.  
  303. VOID
  304. SNMP_FUNC_TYPE
  305. SnmpUtilOidFree(
  306.     IN OUT AsnObjectIdentifier *ObjId
  307.     );
  308.  
  309. SNMPAPI
  310. SNMP_FUNC_TYPE
  311. SnmpUtilVarBindListCpy(
  312.     OUT RFC1157VarBindList *DstVarBindList,
  313.     IN  RFC1157VarBindList *SrcVarBindList
  314.     );
  315.  
  316. SNMPAPI
  317. SNMP_FUNC_TYPE
  318. SnmpUtilVarBindCpy(
  319.     OUT RFC1157VarBind *DstVarBind,
  320.     IN  RFC1157VarBind *SrcVarBind
  321.     );
  322.  
  323. VOID
  324. SNMP_FUNC_TYPE
  325. SnmpUtilVarBindListFree(
  326.     IN OUT RFC1157VarBindList *VarBindList
  327.     );
  328.  
  329. VOID
  330. SNMP_FUNC_TYPE
  331. SnmpUtilVarBindFree(
  332.     IN OUT RFC1157VarBind *VarBind
  333.     );
  334.  
  335. VOID
  336. SNMP_FUNC_TYPE
  337. SnmpUtilPrintAsnAny(
  338.     IN AsnAny *Any
  339.     );
  340.  
  341. VOID
  342. SNMP_FUNC_TYPE
  343. SnmpUtilMemFree(
  344.     IN OUT LPVOID Addr
  345.     );
  346.  
  347. LPVOID
  348. SNMP_FUNC_TYPE
  349. SnmpUtilMemAlloc(
  350.     IN UINT Size
  351.     );
  352.  
  353. LPVOID
  354. SNMP_FUNC_TYPE
  355. SnmpUtilMemReAlloc(
  356.     IN LPVOID Addr,
  357.     IN UINT   NewSize
  358.     );
  359.  
  360. ///////////////////////////////////////////////////////////////////////////////
  361. //                                                                           //
  362. // SNMP debugging definitions                                                //
  363. //                                                                           //
  364. ///////////////////////////////////////////////////////////////////////////////
  365.  
  366. #define SNMP_LOG_SILENT             0x0
  367. #define SNMP_LOG_FATAL              0x1
  368. #define SNMP_LOG_ERROR              0x2
  369. #define SNMP_LOG_WARNING            0x3
  370. #define SNMP_LOG_TRACE              0x4
  371. #define SNMP_LOG_VERBOSE            0x5
  372.  
  373. ///////////////////////////////////////////////////////////////////////////////
  374. //                                                                           //
  375. // SNMP debugging prototypes                                                 //
  376. //                                                                           //
  377. ///////////////////////////////////////////////////////////////////////////////
  378.  
  379. VOID
  380. SNMP_FUNC_TYPE
  381. SnmpUtilDbgPrint(
  382.     IN INT nLogLevel,               // see log levels above...
  383.     IN LPSTR szFormat,
  384.     IN ...
  385.     );
  386.  
  387. #if DBG
  388. #define SNMPDBG(_x_)                SnmpUtilDbgPrint _x_
  389. #else
  390. #define SNMPDBG(_x_)
  391. #endif
  392.  
  393. ///////////////////////////////////////////////////////////////////////////////
  394. //                                                                           //
  395. // Miscellaneous definitions                                                 //
  396. //                                                                           //
  397. ///////////////////////////////////////////////////////////////////////////////
  398.  
  399. #define SNMP_MAX_OID_LEN            0x7f00 // max number of elements in oid
  400.  
  401. ///////////////////////////////////////////////////////////////////////////////
  402. //                                                                           //
  403. // Support for old definitions (support disabled via SNMPSTRICT)             //
  404. //                                                                           //
  405. ///////////////////////////////////////////////////////////////////////////////
  406.  
  407. #ifndef SNMPSTRICT
  408.  
  409. #define SNMP_oidcpy                 SnmpUtilOidCpy
  410. #define SNMP_oidappend              SnmpUtilOidAppend
  411. #define SNMP_oidncmp                SnmpUtilOidNCmp
  412. #define SNMP_oidcmp                 SnmpUtilOidCmp
  413. #define SNMP_oidfree                SnmpUtilOidFree
  414.  
  415. #define SNMP_CopyVarBindList        SnmpUtilVarBindListCpy
  416. #define SNMP_FreeVarBindList        SnmpUtilVarBindListFree
  417. #define SNMP_CopyVarBind            SnmpUtilVarBindCpy
  418. #define SNMP_FreeVarBind            SnmpUtilVarBindFree
  419.  
  420. #define SNMP_printany               SnmpUtilPrintAsnAny
  421.  
  422. #define SNMP_free                   SnmpUtilMemFree
  423. #define SNMP_malloc                 SnmpUtilMemAlloc
  424. #define SNMP_realloc                SnmpUtilMemReAlloc
  425.  
  426. #define SNMP_DBG_free               SnmpUtilMemFree
  427. #define SNMP_DBG_malloc             SnmpUtilMemAlloc
  428. #define SNMP_DBG_realloc            SnmpUtilMemReAlloc
  429.  
  430. #endif // SNMPSTRICT
  431.  
  432. #ifdef __cplusplus
  433. }
  434. #endif
  435.  
  436. #pragma option pop
  437. #endif // _INC_SNMP
  438.